package org.example.game.history;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/22 22:36
 */
public class Solution100344 {

    public static void main(String[] args) {
        Solution100344 solution = new Solution100344();

        System.out.println(solution.minOperations(new int[]{}));
    }

    public int minOperations(int[] nums) {
        int sum = 0;

        for (int i = 0; i < nums.length -2; i++) {
            if(nums[i] == 1){
                continue;
            }
            //revert
            sum++;
            nums[i+1] = nums[i+1] == 1? 0 : 1;
            nums[i+2] = nums[i+2] == 1? 0 : 1;

        }
        if(nums[nums.length-1] == 0 || nums[nums.length-2] == 0){
            return -1;
        }

        return sum;
    }

}
